Borland Online And The Cobb Group Present:


December, 1994 - Vol. 1 No. 12

Debugging OWL 2.0 applications - Building a diagnostic version of the OWL 2.0 library

When you're writing a new application or debugging an existing one, you'll probably use the Turbo Debugger for Windows or the Integrated Debugger from the Integrated Development Environment (IDE) to set breakpoints, view expressions, and monitor messages from the TRACE or WARN macro. If you build your application with the standard ObjectWindows Library (OWL) code, though, you won't be able to perform these debugging tasks on the OWL source files because the compiled library code doesn't include this type of debugging information.

However, when you're building an OWL application using Borland C++ 4.0, you can easily change the Standard Libraries settings. If you select the Diagnostic check box in the TargetExpert dialog box, as shown in Figure A, then the next time you build the project, the IDE will attempt to link a version of the OWL code that contains diagnostic information from the OWL source files.


Figure A - You use the TargetExpert dialog box to link diagnostic versions of the libraries to your application.

Unfortunately, if the IDE tries to link this diagnostic code to your program, you'll see error messages from the linker similar to

Linker Fatal: Unable to open file 'owldwi.lib'

You'll see this message because Borland doesn't ship pre-built diagnostic or debugging versions of the OWL code with Borland C++. (To do so would increase the disk-space requirements dramatically.)

To overcome this limitation, you can use Borland's MAKE.EXE utility to build different versions of the OWL library. In this article, we'll show how you can build the OWL libraries with debugging or diagnostic information, so you can more fully debug an OWL application.

Diagnostic and debugging versions

If you chose to include the OWL source code when you installed Borland C++ 4.0, the installation program added a make file for you to use with the MAKE utility in order to create the various versions of the OWL library. In a default installation, the path and filename for this make file is \BC4\SOURCE\OWL\MAKEFILE.

In general, you can use this make file to create two encapsulations of the OWL code: a static library (using a traditional LIB file) or a dynamic library (using an OWL DLL and a linking LIB file). If you're building a traditional LIB file, you can build it using the small, medium, large, or 32-bit (flat) memory model by specifying an appropriate value for the MODEL command-line macro (MODEL=s, MODEL=m, MODEL=l, or MODEL=f, respectively).

To build a diagnostic version of a static or dynamic OWL library, you'll add the -DDIAGS option to the MAKE command line. If you define the DIAGS macro this way, the MAKE utility defines the constants

__DEBUG 2
__TRACE 1
__WARN 1

when it compiles the OWL source files. The __DEBUG constant enables precondition checks, and the __TRACE and __WARN constants enable the TRACE and WARN diagnostic message macros.

To build a debugging version of either type of library­­one that includes all the symbolic debugging information for using either the Integrated Debugger or Turbo Debugger for Windows­­you'll add the -DDEBUG option to the MAKE command line. If you don't define this macro, you won't be able to set breakpoints or evaluate expressions inside the OWL source files.

Hardware requirements

Before you begin building either a diagnostic or a debugging version of the OWL code, you should be aware that the MAKE utility will need considerable disk space and RAM to be able to build and link this library. For example, if you're going to build a simple diagnostic version of one of the OWL libraries, you'll need to have at least 6 to 10 Mb of free disk space.

If, instead, you decide to build a full debugging version, you'll need to have between 38 and 40 Mb of free disk space. (The increased space requirement is double what you might expect, since the MAKE utility needs to build new versions of each object file (OBJ) and then import that code into a dynamic or static library file.)

In addition to these disk space requirements, you'll need at least 10 to 16 Mb of RAM to build any version of the OWL libraries. (If you don't have at least 10 Mb of RAM, see Running MAKE on a low-memory system.)

Building the diagnostic OWL DLL

To demonstrate how you can use the MAKE utility to create a specific version of the OWL static or dynamic library, let's build a diagnostic version of the OWL DLL and its corresponding static linking library. While building this version of the library requires only a modest amount of disk space, you should be aware that it will take a fair amount of time to complete. On our test machine, for example (a 33 Mhz 80486 DX), building this version took approximately 25 minutes.

To begin, make the OWL source code directory the current directory by entering

cd \BC4\SOURCE\OWL

at a DOS command prompt. Then, start the MAKE utility by entering

make -DDIAGS

(Remember to enter the -DDIAGS option in uppercase text.)

When the MAKE utility finishes building the new diagnostic version of the OWL DLL, it changes the DOS system's current directory to

C:\BC4\SOURCE\OWL\OBJECT\DWI>

This is the location the MAKE utility creates to store the compiled OWL OBJ files. Later, when you've confirmed that the new OWL DLL is working correctly, you can safely delete the files in this directory to reclaim the disk space they occupy.

To reclaim additional space, you can also delete the file OWLDWI.CSM from the \BC4\LIB directory. (This is a precompiled header file the MAKE utility creates and uses when it's building the OWL library.)

Now you can see the new files you've created. To see the new static library that calls the OWL DLL code, enter

dir \BC4\LIB\OWLDWI.LIB

You should see a directory listing that includes the filename OWLDWI.LIB. To see the new diagnostic version of the OWL DLL, enter

dir \BC4\BIN\OWL200D.DLL

You should see a directory listing that includes the name OWL200D.DLL. Now, you can use this diagnostic version of the OWL DLL in your OWL applications.

You may need to build the BIDS library, too

Because the OWL code relies on the Borland International Data Structures (BIDS) classes, when you use a diagnostic or debugging version of the OWL code, you'll use the diagnostic version of the BIDS code in a corresponding format. For example, if you link the diagnostic version of the large model OWL static library code to your application, the IDE will try to link in the diagnostic version of the large model BIDS library.

However, if you received an early version of Borland C++ 4.0, you may need to rebuild the BIDS diagnostic DLL. This is due to some slight discrepancies between the BIDS source files and the pre-built diagnostic version of the BIDS DLL and LIB files. (Borland does include pre-built diagnostic versions of the BIDS libraries with Borland C++ 4.0.)

If the MAKE utility generates Undefined Symbol errors when you build the OWL libraries, rebuilding the BIDS library files will usually correct the error. (This is because the source files contain the definitions of the missing functions and symbols.)

To build a diagnostic version of the BIDS DLL, make the standard class library source code directory the current directory by entering

cd \BC4\SOURCE\CLASSLIB

Then, run the MAKE utility by entering

make -DNAME=BIDS -DSUFFIX=D -DDBG -DDLL -DDOS

(Again, be sure to enter all the command-line options in uppercase text.)

Now you can see the new files you've created. To see the new static library that calls the BIDS DLL code, enter

dir \BC4\LIB\BIDSDI.LIB

You should see a directory listing that includes the filename BIDSDI.LIB. To see the new diagnostic version of the OWL DLL, enter

dir \BC4\LIB\BIDS40D.DLL

You should see a directory listing that includes the name BIDS40D.DLL.

Before you can use the new BIDS DLL in your application, you'll need to copy the DLL into the \BC4\BIN directory in order for your programs to link to this file correctly. (The MAKE utility creates the new DLL in the \BC4\LIB directory by default.) To do this, enter

copy \BC4\LIB\BIDS40D.DLL\
    BC4\BIN\BIDS40D.DLL

at a DOS command prompt.

Conclusion

You can learn a great deal about the OWL library by watching TRACE and WARN messages from the OWL code and setting breakpoints in the source files. Since Borland doesn't supply pre-built diagnostic or debugging versions of these files (due to disk space constraints), you can use the procedure we've shown here to create the library files you need.

Return to the Borland C++ Developer's Journal index

Subscribe to the Borland C++ Developer's Journal


Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.